<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
    
<%@ page import="java.util.List" %>
<%@ page import="model.SuShe"%>
<%@ page import="dao.SuSheDao"%>

<%
	//检查会话中是否有 "student" 属性
	Object fdyObj = session.getAttribute("student");
	if (fdyObj == null) {
	    response.sendRedirect("../view/Login.jsp");
	    return;
	}
%>

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>宿舍信息展示</title>
<link href="../css/Utils.css" rel="stylesheet" type="text/css" />
<link href="../css/List.css" rel="stylesheet" type="text/css" />
<!-- 退出登录专用 -->
   <script type="text/javascript" src="../view/Loginout.js"></script>
</head>
<body>

<!-- 头部 -->
<div class="header" ><br>
<nerong>&nbsp;&nbsp;学生页面&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;&emsp;</nerong>

 <button onclick="confirmLogout('<%= (String)session.getAttribute("student") %>','student')">退出登录</button>

</div><br>

<div class="left" >
<table width="80%" height="80%">
<th>
<nerong>学生可选择内容</nerong>

</th>

<tr>
<td>
<a href="../View_Msg/msgStudent.jsp">&emsp;个人信息</a><br>
</td>
</tr>

<tr>
<td>
<a href="../View_SuShe/SuSheStudent.jsp">&emsp;宿舍信息</a><br>
</td>
</tr>


<tr>
<td>
<a href="../View_fix/StudentFix.jsp">&emsp;宿舍报修</a><br>
</td>
</tr>

<tr>
<td>
<a href = "../View_WeiGui/WeiGuiStudent.jsp">&emsp;违规消息查询</a><br>
</td>
</tr>

<tr>
<td>
<a href = "http://10.0.84.5:8080/JW软工大作业/View_leave/S_Main_Leave.jsp">&emsp;请假</a><br>
</td>
</tr>


</table>

</div>


<div class="context" >
<!-- 这部分是每个大功能的小功能 -->

	
       
            <h2>宿舍信息</h2>
            
            
            	<%
                    	SuSheDao dao = new SuSheDao();                
            			String id=(String)session.getAttribute("student");
                    	List<SuShe> Messages = dao.findSameRoomSuSheData(id); 
                    	SuShe firstSuShe = null;
                        if (Messages != null && !Messages.isEmpty()) {                        
                        	firstSuShe = Messages.get(0);	
                 %>   		
                 	
                 <h4>宿舍号</h4>			            	           	           	                      
            	<p><%= firstSuShe.getRoomid() %></p>
            	<h4>宿舍水电费配额</h4>	
                <p><%= firstSuShe.getQuota() %></p>  
                <h4>宿舍规格</h4>	                    
                <p><%= firstSuShe.getGuige() %></p>           	            	
            	<h4>宿舍成员如下</h4>
                <table class="Alltable">
                    <tr>
                        <th>姓名</th>
                        <th>学号</th>
                        <th>班级</th>                       
                    </tr>
                  
                    <tr>
                       <%    	
                            for (SuShe suShe : Messages) {
                   	%>
                       	<td><%= suShe.getStudentName() %></td>
                        <td><%= suShe.getStudentId() %></td>                      
                        <td><%= suShe.getStudentClass() %></td>                      
                        
                    </tr>
                    <%
                            }
                        } else {
                    %>
                    <tr>
                        <td colspan="3">没有找到对应的宿舍信息</td>
                    </tr>
                    <%
                        }
                    %>
                </table>
                
                
            </div>
        
  
</body>
</html>